# -*- coding: utf-8 -*-
import redis
import requests
import json
import time
import pymysql

# HOST = '127.0.0.1'
# PORT = 3306
# USER = 'root'
# PASSWD = 'zhangym930920'
# DB = 'spider'
# CHARSET = 'utf8mb4'

HOST='oyo-scrapy-database.mysql.rds.aliyuncs.com'
PORT=3306
USER='scrapy'
PASSWD='Podf&T$2'
DB='spider'
CHARSET='utf8mb4'

conn = pymysql.connect(host=HOST, port=PORT, user=USER, passwd=PASSWD, db=DB,charset=CHARSET)
cur=conn.cursor()

RHOST='10.200.20.200'
RPORT=6379
RPASSWORD='zhangym930920'
RDB=1
r = redis.Redis(host=RHOST, port=RPORT, password=RPASSWORD, db=RDB,charset='utf-8',decode_responses=True)
sql="SELECT sync_username,sync_password,CRS_ID,batch_no from ota_back_account_info where batch_no='2019040221' and ota_channel_en='meituan' and verify_time is null"
# sql="SELECT sync_username,sync_password,CRS_ID,batch_no from ota_back_account_info where batch_no=2019032621 and ota_channel_en='ctrip' limit 1"
cur.execute(sql)
datas=cur.fetchall()

for data in datas:
    Ctrip_Username=str(data[0]).strip()
    Ctrip_Password=str(data[1]).strip()
    CRS_ID=data[2]
    batch_no=data[3]


    print(Ctrip_Username,Ctrip_Password,CRS_ID,batch_no)
    r.rpush('hotel_users_meituan',(Ctrip_Username,Ctrip_Password,CRS_ID,batch_no))